package com.zhentao.controller;

import com.zhentao.domain.SysActivity;
import com.zhentao.domain.vo.Result;
import com.zhentao.service.SysActivityService;
import com.zhentao.utils.UserUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/activity")
@Tag(name = "活动管理")
public class ActivityController {
    @Autowired
    private SysActivityService sysActivityService;
    @Autowired
    private UserUtils utils;
//    查询活动
    @PostMapping("/getActivityList")
    @Operation(summary = "查询活动列表")
    public Result getActivityList(){
        List<SysActivity> sysActivities = sysActivityService.activityList();
        return Result.build(sysActivities, 200, "查询成功");
    }
    //    点击领取优惠卷数量减一
    @PostMapping("/updateAcnum")
    @Operation(summary = "更新领取优惠卷数量")
    public Result updateAcnum(@RequestBody SysActivity sysActivity){
       return sysActivityService.updateAcnum(sysActivity);
    }
//    添加活动
    @PostMapping("/addActivity")
    @Operation(summary = "添加活动")
    public Result addActivity(@RequestBody SysActivity sysActivity){
        return sysActivityService.addActivity(sysActivity);
    }
}
